import {takeEvery, put} from 'redux-saga/effects'
import { filter_products, filter_products_success} from '../actions/filter'
import axios from 'axios'
import {API} from '../../config'
function* handleFilter (action) {

    let response = yield axios.post(`${API}/products/filter`,action.payload)
    console.log(response)
    yield put(filter_products_success({
        skip:action.payload.skip,
        size: response.data.size,
        data: response.data.data
    }))
    
    
}

export default function* filterSaga () {
    yield takeEvery(filter_products,handleFilter)
}